(define (square-tree tree) 
  (define nil '())
  (cond ((null? tree) nil) 
        ((not (pair? (car tree))) 
         (cons (square (car tree)) (square-tree (cdr tree)))) 
        (else (cons (square-tree (car tree)) 
                    (square-tree (cdr tree)))))) 

(define (sq-tree-with-map tree) 
  (define nil '()) 
  (map (lambda (x) 
         (cond ((null? x) nil) 
               ((not (pair? x)) (square x)) 
               (else (sq-tree-with-map x)))) 
       tree))
